package com.apestech.framework.util;

public class MessageUtil {

	private boolean isPrint=true;

	public static String getMessage(String messageId, String message, Object... params){
		String sMessage=message;
		if(params==null){
			return message;
		} else {
			//后期将调整成从新框架里接管相关消息接口进行转换
			int ilen=params.length;
			for (int i=0;i<ilen;i++){
				String value=String.valueOf(params[i]);
				sMessage=sMessage.replace("({"+i+"})", value); 
			}
			//后期将调整成从新框架里接管相关消息接口进行转换
			sMessage="error code : "+messageId+"\r    "+sMessage;
		}
		return sMessage;
	}

	public void printMsg(String msg){
		//需要替换System.out.println
		if(isPrint){
			System.out.println(msg);
		}
	}

	public void printMsg(String msg, boolean print){
		if(print){
			System.out.println(msg);
		}
	}

	public void setIsPrint(boolean isPrint){
		this.isPrint=isPrint;
	}

}
